package com.example.demo.api;

import com.example.demo.bean.Response;
import com.example.demo.bean.bis.Appeal;
import com.example.demo.bean.bis.Picture;
import com.example.demo.service.bis.AppealService;
import com.example.demo.utils.ConstantUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zzz
 * @Title: AppealController
 * @ProjectName test
 * @Description: TODO()
 * @date 2018/7/20
 */
@RestController
@Api(value="申诉controller",tags={"申诉接口"})
public class AppealController {

    @Autowired private AppealService appealService ;

    @ApiOperation(value="申诉申请图片" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "起始时间 2018-06-27 08:25:00", required = true,dataType = "String",paramType = "form"),
            @ApiImplicitParam(name = "endTime", value = "结束时间 2018-06-27 08:35:59", required = true,dataType = "String",paramType = "form"),
    })
    @PostMapping(value="/priture")
    public Response insert(String startTime,String endTime){
        List<Picture> list = appealService.selectAll(startTime,endTime);
        return new Response(ConstantUtils.SUCCEED,ConstantUtils.STRING_SUCCEED,list.size()==ConstantUtils.SUCCEED?"":list);
    }


    @ApiOperation(value="申诉申请" )
    @ApiImplicitParam(name = "appeal", value = "申诉实体", required = true,dataType = "Appeal")
    @PostMapping(value="/state")
        public Response insert( Appeal appeal){
        return new Response(ConstantUtils.SUCCEED,ConstantUtils.STRING_SUCCEED,appealService.insert(appeal));
    }

    @ApiOperation(value="申诉列表" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户id", required = true,dataType = "int",paramType = "form"),
    })
    @PostMapping(value="/state/list")
    public Response findByDeptId(Integer id){
        List<Appeal> list = appealService.findByDeptId(id);
        return new Response(ConstantUtils.SUCCEED,ConstantUtils.STRING_SUCCEED,list.size()==ConstantUtils.SUCCEED?"":list);
    }

    @ApiOperation(value="申诉审批" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "申诉主键", required = true,dataType = "int",paramType = "form"),
            @ApiImplicitParam(name = "state", value = "是否同意（25同意 27不同意 ）", required = true,dataType = "int",paramType = "form"),
    })
    @PostMapping(value="/state/update")
    public Response insert(Integer id,Integer state){
        return new Response(ConstantUtils.SUCCEED,ConstantUtils.STRING_SUCCEED,appealService.update(id,state));
    }
}
